package com.example.activity_service.controller;

import com.example.activity_service.service.JPQueryService;
import com.example.activity_service.service.YssQueryService;
import com.example.activity_service.vo.Dui;
import com.example.activity_service.vo.Red;
import com.example.activity_service.vo.Red_goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@ResponseBody
public class YssController {

    @Autowired
    JPQueryService jpQueryService;
    @Autowired
    YssQueryService service;

    @RequestMapping("/chajfsp")
    public List<Red_goods>searchjfsp(){
        List<Red_goods>list=jpQueryService.duica(0);
        return list;
    }
//查询未领取的优惠卷
    @RequestMapping("/chawei")
    public List<Red> chawei(){
        return  service.chawei();
    }

    //查未使用红包
    @RequestMapping("/chahb")
    public List<Red>searchhb(@RequestParam("users")int users)
    {
        List<Red>list=service.searchhb(users);
        return list;
    }

    //查已使用红包
    @RequestMapping("/chasyhb")
    public List<Red>searchsyhb(@RequestParam("users")int users)
    {
        List<Red>list=service.searchsyhb(users);
        return list;
    }


    //查过期红包
    @RequestMapping("/chagqhb")
    public List<Red>searchgqhb(
            @RequestParam("users")int users
    ){

        List<Red>list=service.searchgqhb(users);

        return list;
    }





    @RequestMapping("/xgsyhb")
    public int updatezt
            ( @RequestParam("id")int id,
              @RequestParam("status")int status
              )
    {
        service.updatezt(id, status);
        return 1;
    }



    @RequestMapping("/sggq")
    public int updategq(

            ){

service.updateguoqi();
return 1;

    }

    @RequestMapping("/chacs")
    public int cs(@RequestParam("user_id")int user_id){



        int cs= service.chacs(user_id);
        return cs;
    }


    @RequestMapping("/chasuoyou")
    public List<Red>chasuoyou(){
        List<Red>list=service.searchsuoyou();
        return list;
    }

    @RequestMapping("shanchu")
    public int shanchu(@RequestParam("id")int id){
        service.deletehb(id);
        return 1;
    }

    @RequestMapping("xinzeng")
    public int xinzeng(
            @RequestParam("users")String users,
            @RequestParam("preferentialway")String preferentialway,
            @RequestParam("parvalue")String parvalue,
            @RequestParam("threshold")String threshold,
            @RequestParam("totalissued")String totalissued
    ){
service.tianjiahb(users, preferentialway, parvalue, threshold, totalissued);
return 1;
    }

    @RequestMapping("/update")
    public int xiugai(
            @RequestParam("id")int id,
            @RequestParam("preferentialway")int preferentialway,
            @RequestParam("parvalue")int parvalue,
            @RequestParam("threshold")int threshold,
            @RequestParam("totalissued")int totalissued
    ){
        service.updatehb(id, preferentialway, parvalue, threshold, totalissued);
        return 1;
    }
    @RequestMapping("/yhjxiu")
    public int yhjxiu(  @RequestParam("id")String id,
                        @RequestParam("juan")String juan){
        service.juan(id,juan);
        return 1;
    }

}
